package com.thinkgem.jeesite.common.task;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.modules.ems.service.EmsStudentService;

// 学员学号重建定时任务，由于学号是 yyyyMM+序列，每月月初都要将序列当前值重置为1，具体实现方法为月底（提前一天）创建下月序列，月初（延后一天）删除上月序号
// @Component("seqResetTask")
public class SeqResetTask {
	
	@Autowired
	private EmsStudentService emsStudentService;
	
	//@Scheduled(cron = "0 27 18 * * ?")
	public void createNextStuSeq()
	{
		//获取下月月份
		String month = DateUtils.getAnyMonth(new Date(), 1);
		Map<String,String> param = new HashMap<String,String>();
		param.put("month", month);
		this.emsStudentService.createStuNoSeq(param);
		System.out.println("======创建下月学号生成序列成功======");
	}
	
	//@Scheduled(cron = "0/5 * * * * ?")
	public void dropLastStuSeq()
	{
		String month = DateUtils.getAnyMonth(new Date(), -1);
		Map<String,String> param = new HashMap<String,String>();
		param.put("month", month);
		this.emsStudentService.dropStuNoSeq(param);
		System.out.println("======删除上月学号生成序列成功======");
	}
	
}
